package com.halden.mycache.support.saveStrategy.AOFSaveStrategy.impl;

import com.halden.mycache.Utils.KryoUtil;
import com.halden.mycache.support.saveStrategy.AOFSaveStrategy.IAOFSaveMode;
import com.halden.mycache.support.saveStrategy.AOFSaveStrategy.SaveContext;

/**
 * @Author: halden
 * @Data:2023/2/15 16:36
 * @Description: aof存储模式的kryo实现类
 */
public class AofKryoSerializeSaveMode implements IAOFSaveMode {
    @Override
    public String save(SaveContext context) {
        String s = KryoUtil.writeToString(context);
        return s+'\n';
    }

    @Override
    public SaveContext read(String string) {
        SaveContext saveContext = KryoUtil.readObjectFromString(string, SaveContext.class);
        return saveContext;
    }
}
